document.body.style.fontFamily = 'monospace';

// Replace the console.log with something that also outputs to the gadget.
var oldLog = console.log;
console.log = function() {
  document.body.appendChild(document.createElement('br'));
  document.body.appendChild(
      document.createTextNode(Array.prototype.join.call(arguments, ' ')));
  oldLog.apply(this, arguments);
};

// Callback method that reports back to the test case.
var respond = function(args) {
  console.log('RESPOND: ' + args);
  gadgets.rpc.call(null, 'jsauto-gadgetbridge-response', undefined, args);
};


gadgets.rpc.register('jsauto-gadgetbridge-request', function(code) {
  console.log('REQUEST: ' + code);
  try {
    eval(code);
  } finally {
    if (this['callback']) {
      this['callback']();
    }
  }
});
